server {
    listen 80;
        server_name {{ nginx.project.domain }} {{ nginx.project.domain | regex_replace('^www\\.', '') }};

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name {{ nginx.project.domain }} {{ nginx.project.domain | regex_replace('^www\\.', '') }};
    client_max_body_size 20m;
    ssl_certificate /etc/nginx/cert/{{ nginx.project.domain }}.pem;
    ssl_certificate_key /etc/nginx/cert/{{ nginx.project.domain }}.key;
    location / {
        root   {{ nginx.project.dir }}/{{ nginx.project.name }};
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
}
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   /usr/share/nginx/html;
}
    location ~ \.php$ {
      root {{ nginx.project.dir }}/{{ nginx.project.name }};
      fastcgi_pass unix:/var/run/php/php-fpm.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
    }
}